<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Wally The Sentry Bot: MegaMan/MegaMan.ino File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Wally The Sentry Bot
   &#160;<span id="projectnumber">0.2</span>
   </div>
   <div id="projectbrief">A silly Arduino project to play with sensors, Xbees and a Peggy 2.0 pegboard</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_mega_man_8ino.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">MegaMan/MegaMan.ino File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Control module for Peggy. Creates animations and graphics for Peggy as well as playing audio via MP3 Player Shiled from Sparkfun. Receives alerts from Wally the sentry turret, and takes action as appropriate.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;Wire.h&gt;</code><br/>
<code>#include &lt;SPI.h&gt;</code><br/>
<code>#include &lt;SdFat.h&gt;</code><br/>
<code>#include &lt;SdFatUtil.h&gt;</code><br/>
<code>#include &lt;SFEMP3Shield.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="_mega_man_8h_source.html">MegaMan.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="flash__pics_8h_source.html">flash_pics.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="p2anim_8h_source.html">p2anim.h</a>&quot;</code><br/>
</div><div class="textblock"><div class="dynheader">
Include dependency graph for MegaMan.ino:</div>
<div class="dyncontent">
<div class="center"><img src="_mega_man_8ino__incl.png" border="0" usemap="#_mega_man_2_mega_man_8ino" alt=""/></div>
<map name="_mega_man_2_mega_man_8ino" id="_mega_man_2_mega_man_8ino">
<area shape="rect" id="node13" href="_mega_man_8h.html" title="MegaMan.h" alt="" coords="509,160,600,189"/><area shape="rect" id="node15" href="flash__pics_8h.html" title="flash_pics.h" alt="" coords="664,83,755,112"/><area shape="rect" id="node19" href="p2anim_8h.html" title="p2anim.h" alt="" coords="565,83,640,112"/></map>
</div>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4f757cfc4b07756d0585763433740827"></a><!-- doxytag: member="MegaMan.ino::PEGGY_ADDRESS" ref="ga4f757cfc4b07756d0585763433740827" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga4f757cfc4b07756d0585763433740827">PEGGY_ADDRESS</a>&#160;&#160;&#160;34</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Peggy 2.0's address on the I2C bus. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3e79c6425e8cc6a0ce853eb49a45e5b9"></a><!-- doxytag: member="MegaMan.ino::TWI_FREQ" ref="ga3e79c6425e8cc6a0ce853eb49a45e5b9" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga3e79c6425e8cc6a0ce853eb49a45e5b9">TWI_FREQ</a>&#160;&#160;&#160;300000</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C/TWO bus frequency, 300'000 bits/second. <br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga332352d7fb4b7b02401910478cec92fa">ISR</a> (TIMER5_COMPA_vect)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Timer interrupt Used primarily to check that the UART has been quiet for a while before whitching to our own graphics after having done UART-SPI conversion.  <a href="group___mega_man.html#ga332352d7fb4b7b02401910478cec92fa"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gafd676aabb0da97bf404f50ea4eab3210"></a><!-- doxytag: member="MegaMan.ino::videoTransfer" ref="gafd676aabb0da97bf404f50ea4eab3210" args="(uint8_t count)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>videoTransfer</b> (uint8_t count)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gad3481dd6138035714f76dc5e63d4f313"></a><!-- doxytag: member="MegaMan.ino::imageFromFlash" ref="gad3481dd6138035714f76dc5e63d4f313" args="(unsigned char *)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gad3481dd6138035714f76dc5e63d4f313">imageFromFlash</a> (unsigned char *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copies an image from flash to Peggy. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga2d106db4253178eb0b86bb1f83826fdc"></a><!-- doxytag: member="MegaMan.ino::putPixel" ref="ga2d106db4253178eb0b86bb1f83826fdc" args="(uint8_t, uint8_t, uint8_t)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga2d106db4253178eb0b86bb1f83826fdc">putPixel</a> (uint8_t, uint8_t, uint8_t)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Display single pixel on Peggy through slow method of transferring entire frameBuffer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga1950e89e25c8e1215c11d7accd92ee97">updatePeggyDisplay</a> (char update[])</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This function fills the frameBuffer with some pattern/graphic/text and finally calls the sendBuffer function to transmit the whole buffer to Peggy2.  <a href="group___mega_man.html#ga1950e89e25c8e1215c11d7accd92ee97"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga609b1effb2d33cdee0e09fa8b8b28a26"></a><!-- doxytag: member="MegaMan.ino::alterBuffer" ref="ga609b1effb2d33cdee0e09fa8b8b28a26" args="(char effect[], unsigned char *picture)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>alterBuffer</b> (char effect[], unsigned char *picture)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga64b15cf19ae6a81a307e4b9163b1f717"></a><!-- doxytag: member="MegaMan.ino::sendBuffer" ref="ga64b15cf19ae6a81a307e4b9163b1f717" args="(uint8_t *)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga64b15cf19ae6a81a307e4b9163b1f717">sendBuffer</a> (uint8_t *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Transmit the frameBuffer to Peggy. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gab100da70ae2e4a18ef0d5848ab8ffbaf">processXbeeMsg</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes data (messages) from the XBee via Serial1.  <a href="group___mega_man.html#gab100da70ae2e4a18ef0d5848ab8ffbaf"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4fc01d736fe50cf5b977f755b675f11d"></a><!-- doxytag: member="MegaMan.ino::setup" ref="ga4fc01d736fe50cf5b977f755b675f11d" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>setup</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gafe461d27b9c48d5921c00d521181f12f">loop</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Arduino main loop.  <a href="group___mega_man.html#gafe461d27b9c48d5921c00d521181f12f"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab3c96aa4b0f9d056464804cf754a889e"></a><!-- doxytag: member="MegaMan.ino::MP3player" ref="gab3c96aa4b0f9d056464804cf754a889e" args="" -->
SFEMP3Shield&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gab3c96aa4b0f9d056464804cf754a889e">MP3player</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">MP3 player object. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gad2be532de5ff9d023a146fd3034b7925"></a><!-- doxytag: member="MegaMan.ino::speakerVolume" ref="gad2be532de5ff9d023a146fd3034b7925" args="" -->
const uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gad2be532de5ff9d023a146fd3034b7925">speakerVolume</a> = 40</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">audio volume, where 40 is minimum and 0 maximum volume <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gaabbf4d145c75a803133cdba5d9d81232">header</a> [6] = { 0xde,0xad,0xbe,0xef,1,0}</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">0xdeadbeef is the initialization string of the Peggy 2.0. Once it gets this it will read data from I2C directly to the local framebuffer  <a href="group___mega_man.html#gaabbf4d145c75a803133cdba5d9d81232"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga6133fc6be516b3ec6d15cc5917979f8d"></a><!-- doxytag: member="MegaMan.ino::cmdHeader" ref="ga6133fc6be516b3ec6d15cc5917979f8d" args="[7]" -->
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga6133fc6be516b3ec6d15cc5917979f8d">cmdHeader</a> [7] = { 0xde,0xad,0xbe,0xef,1,1}</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Header which gives Peggy the command in the next byte. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga437ffbfa1e751a31d0497f67084fc934"></a><!-- doxytag: member="MegaMan.ino::globalCounter" ref="ga437ffbfa1e751a31d0497f67084fc934" args="" -->
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga437ffbfa1e751a31d0497f67084fc934">globalCounter</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">global counter used to keep persisten values between function calls <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga571993b3a5645afe9fe29929c2856ceb"></a><!-- doxytag: member="MegaMan.ino::globalFlipFlop" ref="ga571993b3a5645afe9fe29929c2856ceb" args="" -->
boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga571993b3a5645afe9fe29929c2856ceb">globalFlipFlop</a> = 1</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">global flag used to keep persisten values between function calls <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga044badc155ada65f4dbd410a3741f75e">abortFlag</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Set in timer interrupt when XBee message received. Checked and acted upon in main loop every iteration.  <a href="group___mega_man.html#ga044badc155ada65f4dbd410a3741f75e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaccb2653af50979b13c5912a07fe660cc"></a><!-- doxytag: member="MegaMan.ino::sender" ref="gaccb2653af50979b13c5912a07fe660cc" args="" -->
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#gaccb2653af50979b13c5912a07fe660cc">sender</a> = 9</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The sender who's contacting us. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4d43e8212bdc9dbee866506f04effcea"></a><!-- doxytag: member="MegaMan.ino::cmd" ref="ga4d43e8212bdc9dbee866506f04effcea" args="" -->
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga4d43e8212bdc9dbee866506f04effcea">cmd</a> = 9</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The sender's requested command. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga0f5ff78526ce1d8a53cfd7cfdb2d1f59"></a><!-- doxytag: member="MegaMan.ino::cmdParam" ref="ga0f5ff78526ce1d8a53cfd7cfdb2d1f59" args="" -->
char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___mega_man.html#ga0f5ff78526ce1d8a53cfd7cfdb2d1f59">cmdParam</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The sender's command parameters. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Control module for Peggy. Creates animations and graphics for Peggy as well as playing audio via MP3 Player Shiled from Sparkfun. Receives alerts from Wally the sentry turret, and takes action as appropriate. </p>
<p>MegaMan is an Arduiono MEGA 2560 which serves as the main master module in the Peggy-MegaMan-Wally trio. It sends data to be displayed to Peggy (raw framebuffer as well as commands for Peggy's builtin functions). MegaMan also listens (via XBee wireless) to alerts from Wally if Wally has detected movement, and initiates apropriate action (sound and visual alerts) if an "intruder" is found.</p>
<p>MegaMan has a Sparkfun MP3 Player Shield attached, as well as a series 1 XBee to talk to Wally (and a log server). It communicates with Peggy over I2C.</p>
<dl class="copyright"><dt><b>Copyright:</b></dt><dd>Copyright 2012 Ole Jakob Skjelten. All rights reserved.</dd></dl>
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>
<p>You should have received a copy of the GNU General Public License along with this program. If not, see &lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;. </p>
</div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_mega_man_8ino.html">MegaMan.ino</a>      </li>

    <li class="footer">Generated on Thu May 24 2012 00:05:01 for Wally The Sentry Bot by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
